package com.yootk.main;

import com.yootk.config.YootkProfileConfig;
import com.yootk.vo.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * Environment与Profile管理
 */
public class Demo05_Profile {
    private static final Logger LOGGER = LoggerFactory.getLogger(Demo05_Profile.class);

    public static void main(String[] args) {
        test1();
    }

    public static void test1() {
        // 注解方式启动Spring容器
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.getEnvironment().setActiveProfiles("dev");  // 设置环境
        context.register(YootkProfileConfig.class);         // 注册配置类
        context.refresh();  // 容器刷新
        Message message = context.getBean(Message.class);   // 获取指定类型的Bean
        LOGGER.info("获取message.path属性：{}", message.getPath());
    }
}
